package com.rn.gypsophila.rabbitmq.mq;

import com.rn.gypsophila.rabbitmq.EventMessage;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import static com.rn.gypsophila.rabbitmq.config.RabbitmqConfig.BIZ_EXCHANGE;
import static com.rn.gypsophila.rabbitmq.config.RabbitmqConfig.BIZ_ROUTING_KEY;

/**
 * Description: 消息生产者
 *
 * @author 然诺
 * @date 2019/8/7
 */
@Slf4j
@Component
@AllArgsConstructor
public class TxMessageProducer extends AbstractTxMessageProducer {

    /**
     * 发送下单事件消息
     */
    public void send(EventMessage eventMessage) {
        MessageMeta messageMeta = new MessageMeta();
        messageMeta.setExchange(BIZ_EXCHANGE);
        messageMeta.setRoutingKey(BIZ_ROUTING_KEY);
        messageMeta.setMessageId(String.valueOf(eventMessage.getGoodsId()));
        messageMeta.setPayload(eventMessage);
        super.send(messageMeta);
    }

}
